import http from '@/utils/http'
import convert from '@/utils/model-convert'
import {SearchArgument} from '@/models/customer/desktop/statistics'

const ITEM_ARREARAGE_URL = '/rest/customer/report/item-charge-statistics/item-arrearage'
const ITEM_STATISTICS_URL = '/rest/customer/report/item-charge-statistics/item-statistics'
const YESTERDAY_EFFECT_URL = '/rest/customer/report/item-solution-page-reports/yesterday-effect'
const ALL_CONSUMPTIONS_URL = '/rest/customer/report/item-consumptions/all-consumptions'

export default {
  // 项目欠费统计
  itemArrearage (cb) {
    http.get(ITEM_ARREARAGE_URL).then(response => cb(response))
      .catch(trace => cb(trace.response))
  },
  // 项目总消费统计
  itemStatistics ({search}, cb) {
    http.get(ITEM_STATISTICS_URL, {
      params: convert.toJson(search, SearchArgument)
    }).then(response => cb(response))
      .catch(trace => cb(trace.response))
  },
  // 昨日效果统计
  yesterdayEffect (cb) {
    http.get(YESTERDAY_EFFECT_URL).then(response => cb(response))
      .catch(trace => cb(trace.response))
  },
  // 总消费统计
  allConsumptions (cb) {
    http.get(ALL_CONSUMPTIONS_URL).then(response => cb(response))
      .catch(trace => cb(trace.response))
  }
}
